import Vue from 'vue'
import Vuex, { Store } from 'vuex'

Vue.use(Vuex)
const files = require.context('./modules', false, /\.js$/)
let modules = {
  state: {},
  mutations: {},
  actions: {},
  getters: {}
}

files.keys().forEach(key => {
  modules.state = {
    ...files(key)['state']
  }
  modules.mutations = {
    ...files(key)['mutations']
  }
  modules.actions = {
    ...files(key)['actions']
  }
  modules.getters = {
    ...files(key)['getters']
  }
  // Object.assign(modules.state, files(key)["state"]);
  // Object.assign(modules.mutations, files(key)["mutations"]);
  // Object.assign(modules.actions, files(key)["actions"]);
  // Object.assign(modules.getters, files(key)["getters"]);
})
const store = new Store(modules)
export default store
